//
//  SelectReportView.m
//  diaoyuren
//
//  Created by 钓鱼人 on 16/3/23.
//  Copyright © 2016年 game. All rights reserved.
//

#import "SelectReportView.h"



@interface SelectReportView ()

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *backWidth;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *bachight;

@property (nonatomic,strong) NSString *selectText;

@end

@implementation SelectReportView

-(void)awakeFromNib{
    self.backgroundColor = TouMingBlack;
    
    self.backWidth.constant = SCREEN_WIDTH-60;
    
    self.bachight.constant = SCREEN_WIDTH*5/6;
    
    self.selectText = @"NO";

}
- (IBAction)cancelClick:(id)sender {
    [self CancelSelct];
}

-(void)CancelSelct{
    for (int i=0; i<5; i++) {
        UIButton *btn = [self viewWithTag:i+10];
        btn.selected = NO;
    }
    
    self.selectText = @"NO";
    
    self.alpha = 0;
    [self.fatherCtrl.view sendSubviewToBack:self];
}


- (IBAction)sureClick:(id)sender {
    
    if ([self.selectText isEqualToString:@"NO"]) {
        [Manager GetHudWhithText:@"请选择举报理由" AndFatherView:self];
    }else{
    
        if (self.model.pid&&self.model.fid) {
            
             NSUserDefaults *ud=[NSUserDefaults standardUserDefaults];
            
            NSDictionary *dic = @{
                                  @"report_select":self.selectText,
                                  @"message":self.selectText,
                                  @"reportsubmit":@"true",
                                  @"rid":self.model.pid,
                                  @"fid":self.model.fid,
                                  @"formhash":[ud valueForKey:@"formhash"],
                                  };
            
             [[Manager sharedManager]ResponseWhithURL:reporUrl AndParameter:dic AndCompletionType:^(id responseObject, DIEError *error) {
                 
             }];
        }
        
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.7 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            
            [self CancelSelct];

        });
    }
}


- (IBAction)selectClick:(UIButton *)sender {
    
    for (int i=0; i<5; i++) {
        
        UIButton *btn = [self viewWithTag:i+10];
        if (btn.tag!=sender.tag) {
             btn.selected = NO;
        }
    }

    
    sender.selected = !sender.selected;
    
    if (sender.selected) {
        self.selectText = sender.currentTitle;
    }else{
        self.selectText = @"NO";
    }
}



/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
